//#include <QApplication>
#include <iostream>

//#include "mainwindow.h"

#include "DataTypes.h"
#include "Constants.h"
#include "message.h"
#include "serialportconnector.hpp"
#include "physicalconnector.hpp"
#include "stringlogger.hpp"
#include "MessageParser.hpp"
#include "readanddestroy.h"

void testMessageParser()
{
    MessageParser parser;
    const unsigned char msg[] = {0x92, 0x13, 0x58, 0xF9, 0xF0, 0x00,
                        0x30, 0x61, 0x34, 0x99, 0x20, 0x20,
                        0x41, 0x30, 0x61, 0x34, 0x88, 0x20,
                        0x20, 0x41, 0x93};
    //Data msgvec(msg, msg+21);
    //std::cout << std::string(parser.getMessageData(msgvec).data());

}
void arendi()
{
    Message pingPong;
    SerialPortConnector serialconnector;
    pingPong.setPayload(Data(PING, PING+1));
    Connectors::PhysicalConnector connector(&serialconnector, PartiesAddresses(PHYSICAL, 0x58, 0x13), pingPong);
    ReadAndDestroy rnd = ReadAndDestroy(connector);
    rnd.readCodes();
    rnd.readAndDestroy();

}
int main(int argc, char *argv[])
{
//    QApplication a(argc, argv);
//    MainWindow w;
//    w.show();
//    testMessageParser();
/*    Message clearDTC, readDTC, pingPong;
    pingPong.setPayload(Data(PING, PING+1));
    readDTC.setPayload(Data(READ_DTC, READ_DTC+2));
    clearDTC.setPayload(Data(CLEAR_DTC, CLEAR_DTC+2));
    SerialPortConnector serialconnector;
    Connectors::PhysicalConnector connector(&serialconnector, PartiesAddresses(PHYSICAL, 0x58, 0x13), pingPong);
    connector.startCommunication();
    Message response = connector.send(readDTC);
    StringLogger::getInstance() << response;
*/
    arendi();

    return 0;//a.exec();
}
